[In]
def subtract(a,b):
print=(f"subtracting{a} - {b}")
return a-b
def add(a,b):
print (f"adding{a}+{b}")
return a+b
def multily(a,b):
print(f"multilying {a}*{b}")
return a*b
def divide(a,b):
print(f"dividing{a}/{b}")
return a/b
print('let`s do some math')
candy=subtract(20,5)
soda=add(1,2)
man=multily(10,20)
woman=divide(30,15)
print("There have {} candy {} soda {} man {} woman ".format(candy,soda,man,woman))
###注意format如果要這樣用會像這樣e.g. print("There heva st{}".format(bug))
#注意後面的brackets
[Out]
let`s do some math
adding1+2
multilying 10*20
dividing30/15
There have 15 candy 3 soda 200 man 2.0 woman
確認是否了解return的意思?